Skip to content

Conversation

@adamdempsey90
Copy link
Contributor

Debug build of artemis crashed in the constants comparison (of h specifically). Seemed like a stupid floating point problem that was solved by making the comparison <= instead of <. I also went ahead and split out the difference and scale into separate variables for possible future debugging.

bool eps_equal(const Real &a, const Real &b) const {
const Real diff = std::abs(a - b);
const Real scale = 0.5 * (std::abs(a) + std::abs(b));
return diff / (scale + 1e-100) <= EPS;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little surprised this is more robust.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something to do with storing the result of the operations before the comparison to eps?
https://godbolt.org/z/vc848vMds

Copy link
Contributor Author

@adamdempsey90 adamdempsey90 May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or doing 0 < EPS * 1e-27 is not well defined (in the sense the RHS is set to 0?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think not dividing is maybe technically better. But changing < to <= and storing the pieces could for sure matter.

@Yurlungur Yurlungur merged commit dbea3a1 into lanl:main May 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants